package com.groupbuying.payproducer.service.impl;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.shade.com.alibaba.fastjson.JSON;
import com.aliyun.openservices.shade.com.alibaba.fastjson.serializer.SerializerFeature;
import com.groupbuying.payproducer.aliPay.AliPay;
import com.groupbuying.payproducer.aliPay.AliPayNativeConstants;
import com.groupbuying.payproducer.connector.OrderFeign;
import com.groupbuying.payproducer.connector.StoreFeign;
import com.groupbuying.payproducer.connector.SysconfigFeign;
import com.groupbuying.payproducer.constants.BalancePayConstans;
import com.groupbuying.payproducer.constants.CommonConstants;
import com.groupbuying.payproducer.constants.CurrencyPayConstans;
import com.groupbuying.payproducer.constants.PayInfoEnumConstants;
import com.groupbuying.payproducer.domain.PayInfoDO;
import com.groupbuying.payproducer.domain.PayOrderRelDO;
import com.groupbuying.payproducer.dto.PaySuccessResultDTO;
import com.groupbuying.payproducer.mq.PayMQConfig;
import com.groupbuying.payproducer.service.PayInfoService;
import com.groupbuying.payproducer.service.PayOrderRelService;
import com.groupbuying.payproducer.service.PayResultService;
import com.groupbuying.payproducer.utils.DateUtils;
import com.groupbuying.payproducer.utils.NumberValidator;
import com.groupbuying.payproducer.utils.apiresult.ApiResult;
import com.groupbuying.payproducer.wxpay.WXPayConstants;
import com.groupbuying.payproducer.wxpay.WXPayMsgConfig;
import com.groupbuying.payproducer.wxpay.WXPayUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@Service
public class PayResultServiceImpl implements PayResultService {

    public static final Logger LOGGER = LoggerFactory.getLogger(PayResultServiceImpl.class);
    @Autowired
    private PayInfoService payInfoService;

    @Autowired
    private PayOrderRelService payOrderRelService;
    @Autowired
    private OrderFeign orderFeign;
    @Autowired
    private SysconfigFeign sysconfigFeign;

    @Autowired
    private Producer producer;

    @Autowired
    private StoreFeign storeFeign;

    @Value("${Commodity_Order_Config.counterId}")
    private String counterId;

    /**
     * 获取支付成功详情
     *
     * @param paramMap
     * @return
     */
    @Override
    public ApiResult payDealForSuc(Map<String, String> paramMap) {
        //解析map参数
        //支付单ID
        String tempParam = paramMap.get("payId");
        String payId = tempParam == null ? null : tempParam;

        //判断请求参数不为空
        if (StringUtils.isEmpty(payId)) {
            return ApiResult.paramIsNull();
        }

        //获取预支付信息
        PayInfoDO payInfoDO = payInfoService.get(payId);
        //获取关联订单号
        PayOrderRelDO payOrderRelDO = payOrderRelService.getRelBuyPayId(payId);
        //获取订单信息
        Map orderMap = orderFeign.getOrderForPay(payOrderRelDO.getOrderId());

        //通过订单号判断否属于够样优店
        boolean curNotify = orderMap.get("orderId").toString().substring(4, 7).equals("000");
        String backCurrencyRatio = "";
        if (curNotify) {
            //商户积分规则
            Map ruleMap = new HashMap();
            ruleMap.put("ruleId", orderMap.get("opxRuleId"));
            ruleMap.put("delFlag", CommonConstants.COMMON_FLAG_UNDEL);
            Map rulesMap = sysconfigFeign.getStoreOpexRule(ruleMap);
            orderMap.putAll(rulesMap);
            backCurrencyRatio = orderMap.get("backCurrencyRatio").toString();
        }


//        /**
//         * 同步修改订单状态,并对各个中心发送修改消息
//         */
//        boolean res = paySuccessStateChange(payInfoDO, payOrderRelDO, orderMap, backCurrencyRatio, curNotify);

        /**
         * 返回信息组合
         */
//        if (res) {
            //重新查询支付信息
            payInfoDO = payInfoService.get(payId);
            PaySuccessResultDTO paysucc = new PaySuccessResultDTO(payInfoDO);
            //获取订单金额
            String payCost = orderMap.get("orderPrice").toString();
            paysucc.setCost(payCost + "元");
            paysucc.setOrderId(payOrderRelDO.getOrderId());
            if (PayInfoEnumConstants.ENUM_PAYTYPE_CUR.equals(payInfoDO.getPayType()) && curNotify) {
                //TODO 处理积分取整的问题(目前是向下舍去保留两位)
                //得出的数据是负值表示积分支出
                paysucc.setIntegral("-" + new BigDecimal(payCost).multiply(new BigDecimal(orderMap.get("currencyPayDiscount").toString())).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN) + "分");
                paysucc.setPayCurrency(new BigDecimal(payCost).multiply(new BigDecimal(orderMap.get("currencyPayDiscount").toString())).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN) + "分");
            } else if (curNotify) {
                //TODO 处理积分取整的问题(目前是向下舍去保留两位)
                //得出的数据是正值表示获得积分
                paysucc.setIntegral("+" + new BigDecimal(payCost).multiply(new BigDecimal(orderMap.get("backCurrencyRatio").toString())).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN) + "分");
                paysucc.setPayCurrency(new BigDecimal(payCost).multiply(new BigDecimal(orderMap.get("backCurrencyRatio").toString())).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN) + "分");
            } else {
                paysucc.setIntegral("+0.00分");
                paysucc.setPayCurrency("0.00分");
            }
            return ApiResult.success(paysucc);
//        }
//        return ApiResult.failure("同步修改状态失败");


    }

    /**
     * 积分支付异步回执接口
     * @param requestParam 请求发送数据
     * @return 成功状态 成功：success
     */
    @Override
    public String currencyPaymentCallback(Map<String, Object> requestParam) {
        //1.打印接收参数
        LOGGER.info("打印积分支付回执参数信息:{}",JSON.toJSON(requestParam));

        final String retMsg = "success";
        String baseLog = "积分支付异步回执信息，";



//                2.参数解析
        String currencyCode = requestParam.get("currencyCode") == null?null : requestParam.get("currencyCode").toString();
        String message = requestParam.get("message") == null?null : requestParam.get("message").toString();
        String payCur = requestParam.get("payCurrency") == null?null : requestParam.get("payCurrency").toString();
        String orderNum = requestParam.get("orderNum") == null?null : requestParam.get("orderNum").toString();
        //3.验证参数正确性
        if (StringUtils.isEmpty(currencyCode) ){
            LOGGER.error("{}交易状态码为空,第三方id:{}",baseLog,orderNum);
            return retMsg;
        }

        if (StringUtils.isEmpty(orderNum)){
            LOGGER.error("{}第三方支付单号为空,第三方id:{}",baseLog,orderNum);
            return retMsg;
        }

        if (StringUtils.isEmpty(payCur) || !NumberValidator.isNumber(payCur)){
            LOGGER.error("{}交易积分为空或者金额不是数字,第三方id:{}",baseLog,orderNum);
            return retMsg;
        }

        //4.回执状态不是成功状态
        if (!CurrencyPayConstans.CURRENCY_PAY_SYN_RESULT_SUCCESS.equals(currencyCode)) {
            LOGGER.error("{}支付状态为不成功，积分回执信息支付单号：{},返回信息：{}，交易状态：{}",
                    baseLog,orderNum,message,currencyCode);
            return retMsg;
        }

        LOGGER.info("积分支付异步返回信息准备发送消息；积分支付，状态:{}" ,currencyCode);
        //5.发送mq异步处理支付返回信息
        try {
            String responseStr = JSON.toJSONString(requestParam,
                    SerializerFeature.DisableCircularReferenceDetect);
            //发送消息至支付订单消费中心
            Message messageUpdateOrderState = new Message(PayMQConfig.TOPIC,
                    PayMQConfig.TAG_CUR_PAYBACK, responseStr.getBytes());

            producer.send(messageUpdateOrderState);
            LOGGER.info("积分支付异步回执消息发送成功");
        } catch (Exception e) {
            LOGGER.error("支付单号：{},积分支付回调发送至后续处理mq失败！ 状态:{},msg{}",
                    orderNum,currencyCode,message);
            //TODO 暂时做消息接收失败处理，后期应该将消息保存，后期统一异常处理
            return retMsg;
        }
        return retMsg;
    }

    /**
     * 余额支付异步回执接收接口
     * @param resultMap	请求发送数据
     * @return
     */
    @Override
    public String balancePaymentCallback(Map<String,Object> resultMap) {
        //先打印参数
        LOGGER.info("打印余额支付回执参数信息:{}",JSON.toJSON(resultMap));

        final String retMsg = "success";
        //1. 解析参数
        String balanceCode = resultMap.get("balanceCode") == null?null : resultMap.get("balanceCode").toString();
        String message = resultMap.get("message") == null?null : resultMap.get("message").toString();
        String payMoney = resultMap.get("payMoney") == null?null : resultMap.get("payMoney").toString();
        String orderNum = resultMap.get("orderNum") == null?null : resultMap.get("orderNum").toString();

        if (StringUtils.isEmpty(balanceCode) || !NumberValidator.isNumber(balanceCode)){
            LOGGER.error("余额异步回执信息，交易状态码为空或者金额不是数字");
            return retMsg;
        }

        if (StringUtils.isEmpty(orderNum)){
            LOGGER.error("余额异步回执信息，第三方支付单号为空");
            return retMsg;
        }

        if (StringUtils.isEmpty(payMoney)){
            LOGGER.error("余额异步回执信息交易金额为空");
            return retMsg;
        }

        //2. 回执状态不是成功状态
        if (!BalancePayConstans.BALANCE_PAY_SUCCESS.equals(balanceCode)) {
            LOGGER.error("余额支付异步返回信息支付状态为不成功，余额回执信息支付单号：{},返回信息：{}，交易状态：{}", orderNum,message,balanceCode);
            return retMsg;
        }

        //3. 发送mq异步处理支付返回信息
        try {
            LOGGER.info("余额支付异步返回信息准备发送消息；余额支付，状态:{}" ,balanceCode);
            String responseStr = JSON.toJSONString(resultMap, SerializerFeature.DisableCircularReferenceDetect);
            //发送消息至支付订单消费中心
            Message messageUpdateOrderState = new Message(PayMQConfig.TOPIC, PayMQConfig.TAG_BAL_PAYBACK, responseStr.getBytes());
            producer.send(messageUpdateOrderState);
            LOGGER.info("余额支付异步回执消息发送成功");
        } catch (Exception e) {
            LOGGER.error("支付单号：{},余额支付回调发送至后续处理mq失败！ 状态:{},msg{}",orderNum,balanceCode,message);
            //TODO 暂时做消息接收失败处理，后期应该将消息保存，后期统一异常处理
            return retMsg;
        }
        return retMsg;
    }

    /**
     * 支付成功，同步修改状态信息及各个中心通知
     *
     * @param payInfoDO         当前支付订单对象
     * @param orderMap          当前订单Map
     * @param backCurrencyRatio 现金支付返积分率
     */
    public boolean paySuccessStateChange(PayInfoDO payInfoDO, PayOrderRelDO payOrderRelDO, Map orderMap, String backCurrencyRatio, boolean curNotify) {

        //更新的结果预设是成功的，如果修改失败为0
        int updateResult = 0;
        //如果支付单状态不是支付成功
        if (!PayInfoEnumConstants.ENUM_PAYSTATE_SUCPAY.equals(payInfoDO.getPayState())) {
            payInfoDO.setPayState(PayInfoEnumConstants.ENUM_PAYSTATE_SUCPAY);
            payInfoDO.setGmtModified(new Date());
            updateResult = payInfoService.update(payInfoDO);
            LOGGER.info("同步修改支付单信息! 支付单号" + payInfoDO.getId() + "原状态：" + payInfoDO.getPayState() + "修改后状态：" + PayInfoEnumConstants.ENUM_PAYSTATE_SUCPAY);
        } else {
            return true;
        }

        if (updateResult > 0) {
            //设置订单中心消息传递消息体
            Map<String, Object> orderParam = new HashMap<>();
            orderParam.put("orderId", orderMap.get("orderId"));
            //通知订单中心修改
            try {
                Message orderMessage = new Message(PayMQConfig.ORDER_TOPIC, PayMQConfig.ORDER_TAG_PAY,
                        JSON.toJSONString(orderParam, SerializerFeature.DisableCircularReferenceDetect).getBytes());
                producer.send(orderMessage);
            } catch (Exception e) {
                e.printStackTrace();
                LOGGER.error("订单中心同步消息传递错误：支付单号：" + payInfoDO.getId() + "，订单号：" + orderMap.get("orderId"));
            }

            //非积分支付需要通知积分中心为用户增加返现积分
            if (!PayInfoEnumConstants.ENUM_PAYTYPE_CUR.equals(payInfoDO.getPayType()) && curNotify) {
                try {
                    //设置积分中心消息传递消息体
                    Map<String, Object> currencyParam = new HashMap<>();
                    currencyParam.put("payId", payInfoDO.getId());
                    //用户ID
                    currencyParam.put("customerId", orderMap.get("customerId"));
                    //支付金额
                    currencyParam.put("consumptionAmount", orderMap.get("orderPrice"));
                    //消费返积分率
                    currencyParam.put("backCurrencyRatio", backCurrencyRatio);
                    Message currencyMessage = new Message(PayMQConfig.CURRENCY_TOPIC, PayMQConfig.CURRENCY_TAG_ADD,
                            JSON.toJSONString(currencyParam, SerializerFeature.DisableCircularReferenceDetect).getBytes());
                    producer.send(currencyMessage);
                } catch (Exception e) {
                    e.printStackTrace();
                    LOGGER.error("积分中心同步消息传递错误：支付单号：" + payInfoDO.getId() + "，订单号：" + orderMap.get("orderId"));
                }
            }
            //设置分账中心消息传递内容
            try {
                Map<String, Object> settleParam = new HashMap<>();
                settleParam.put("orderId", orderMap.get("orderId"));
                settleParam.put("outTradeNo", payOrderRelDO.getOutTradeNo());
                settleParam.put("ruleId", orderMap.get("opxRuleId"));
                //如果是微信或者支付宝支付
                if (PayInfoEnumConstants.ENUM_PAYTYPE_WX.equals(payInfoDO.getPayType()) || PayInfoEnumConstants.ENUM_PAYTYPE_ALI.equals(payInfoDO.getPayType())) {
                    settleParam.put("totalAmount", payInfoDO.getPayMoney());
                    //积分支付
                } else if (PayInfoEnumConstants.ENUM_PAYTYPE_CUR.equals(payInfoDO.getPayType())) {
                    settleParam.put("totalAmount", payInfoDO.getPayCur());
                    //余额支付
                } else if (PayInfoEnumConstants.ENUM_PAYTYPE_BAL.equals(payInfoDO.getPayType())) {
                    settleParam.put("totalAmount", payInfoDO.getPayBalance());
                }
                //收银台ID
                settleParam.put("counterId", orderMap.get("counterId"));
                //用户ID
                settleParam.put("customerId", orderMap.get("customerId"));
                //代表支付分账
                settleParam.put("settleType", "0");
                settleParam.put("payType", payInfoDO.getPayType());
                settleParam.put("payChannel", payInfoDO.getPayChannel());

                Message settleMessage = new Message(PayMQConfig.SETTLE_TOPIC, PayMQConfig.SETTLE_TAG_SPLIT,
                        JSON.toJSONString(settleParam, SerializerFeature.DisableCircularReferenceDetect).getBytes());
                producer.send(settleMessage);
            } catch (Exception e) {
                e.printStackTrace();
                LOGGER.error("分账中心同步消息传递错误：支付单号：" + payInfoDO.getId() + "，订单号：" + orderMap.get("orderId"));
            }
        }
        return updateResult == 1 ? true : false;
    }


    /**
     * 微信支付回执处理接口
     *
     * @param request
     * @return
     * @throws Exception
     */
    @Override
    public String weChatPaymentCallback(HttpServletRequest request) {

        LOGGER.info("=================notify=============");
        Map<String, String> resp = new HashMap<>();
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
        //解析回传参数
        Map<String, String> resultMap = WXPayUtil.xmlParserCallback(request);
        LOGGER.info("微信回执数据信息：" + resultMap.toString());
        //验证回执签名
        boolean verifyResult = false;
        verifyResult = WXPayUtil.isSignatureValid(resultMap, WXPayMsgConfig.KEY);
        LOGGER.info("=================verifyResult：=============" + verifyResult);
        //签名不成功
        if (!verifyResult) {
            LOGGER.error("支付单号：" + resultMap.get("out_trade_no") + ",微信内部单号：" + resultMap.get("transaction_id") + "签名验证未通过");
            resp.put("return_code", WXPayConstants.SUCCESS);
            resp.put("return_msg", "OK");
            return WXPayUtil.mapToXml(resp);
        }
        //回执状态不是成功状态
        if (!WXPayConstants.SUCCESS.equals(resultMap.get("return_code"))) {
            //TODO 支付回来的不是成功状态的怎么处理
            LOGGER.error("支付单号：" + resultMap.get("out_trade_no") + ",微信内部单号：" + resultMap.get("transaction_id") + "支付回执状态："+resultMap.get("return_code"));
            resp.put("return_code", WXPayConstants.SUCCESS);
            resp.put("return_msg", "OK");
            return WXPayUtil.mapToXml(resp);
        }
        try {
            LOGGER.info("准备发送消息；验证签名通过，return_code：" + resultMap.get("return_code"));
            String responseStr = JSON.toJSONString(resultMap, SerializerFeature.DisableCircularReferenceDetect);
            //发送消息至支付订单消费中心
            Message messageUpdateOrderState = new Message(PayMQConfig.TOPIC, PayMQConfig.TAG_WX_PAYBACK, responseStr.getBytes());
            producer.send(messageUpdateOrderState);
            LOGGER.info("消息发送成功");
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("支付单号：" + resultMap.get("out_trade_no") + ",微信支付回调发送至后续处理mq失败！ 原因:" + e.getMessage());
            //TODO 暂时做消息接收失败处理，后期应该将消息保存，后期统一异常处理
            resp.put("return_code", WXPayConstants.FAIL);
            resp.put("return_msg", "消息传递失败");
            return WXPayUtil.mapToXml(resp);
        }
        resp.put("return_code", WXPayConstants.SUCCESS);
        resp.put("return_msg", "OK");
        return WXPayUtil.mapToXml(resp);

    }

    /**
     * 支付宝支付异步回执处理接口
     * @param requestParams 回执参数
     * @return
     */
    @Override
    public String aliPaymentCallback(Map<String, String> requestParams) {
        String result = "";
        LOGGER.info("支付宝异步回执数据信息：{}" , requestParams.toString());
        Map<String, String> initParams = sysconfigFeign.getByAppliName(AliPayNativeConstants.APPLICATION_NAME);
        Map<String, String> param = AliPay.aliPayCallBackVerify(requestParams, initParams);
        if (StringUtils.isEmpty(param.get("flag")) || "false".equals(param.get("flag"))) {
            LOGGER.error("签名验证失败");
            result = "fail";
            return result;
        }
        LOGGER.info("验证签名成功,参数详情:{}",param);
        //获取回执信息中的订单状态
        String tradeStatus = param.get("trade_status");
        //交易成功
        if("TRADE_SUCCESS".equals(tradeStatus)){
            LOGGER.info("支付交易状态成功");
            try {
                LOGGER.info("准备发送消息");
                String responseStr = JSON.toJSONString(param, SerializerFeature.DisableCircularReferenceDetect);
                //发送消息至支付订单消费中心
                Message messageUpdateOrderState = new Message(PayMQConfig.TOPIC, PayMQConfig.TAG_ALI_PAYBACK, responseStr.getBytes());
                producer.send(messageUpdateOrderState);
                LOGGER.info("消息发送成功");
            } catch (Exception e) {
                e.printStackTrace();
                LOGGER.error("支付单号：{},支付宝支付回调发送至后续处理mq失败！ 原因:{}" ,param.get("out_trade_no") , e.getMessage());
                //TODO 暂时做消息接收失败处理，后期应该将消息保存，后期统一异常处理
                result = "fail";
                return result;
            }
        //交易关闭
        }else if ("TRADE_CLOSED".equals(tradeStatus)){
            LOGGER.info("支付交易状态关闭,第三方支付单号：{}",param.get("out_trade_no"));
        //交易完成
        }else if ("TRADE_FINISHED".equals(tradeStatus)){
            LOGGER.info("支付交易状态完成，表示退款完成回不可退款状态.第三方支付单号：{}",param.get("out_trade_no"));

        }
        result = "success";
        return result;
    }

    /**
     * 通过支付单ID获取用于微信通知的信息回执
     *
     * @param id 支付单id
     * @return
     */
    @Override
    public Map<String, String> getInfoForCurrencyWeChatRemind(String id) {
        Map<String, String> returnParam = new HashMap<>();
        try {
            //获取预支付信息
            PayInfoDO payInfoDO = payInfoService.get(id);
            //获取关联订单号
            PayOrderRelDO payOrderRelDO = payOrderRelService.getRelBuyPayId(id);
            //获取订单信息
            Map orderMap = orderFeign.getOrderForPay(payOrderRelDO.getOrderId());
            String counterId = "";
            if ("002".equals(payOrderRelDO.getOrderId().substring(4,7))){
                counterId = this.counterId;
            }else{
                counterId =orderMap.get("counterId").toString();
            }


            Map<String, Object> storeParams = new HashMap<>();
            storeParams.put("counterId", counterId);
            Map<String, String> shop = storeFeign.getStoreShopByCounterId(storeParams);

            returnParam.put("shopName", shop.get("storename"));
            returnParam.put("formId", payOrderRelDO.getFormId());
            returnParam.put("orderId", payOrderRelDO.getOrderId());
            returnParam.put("payTime", DateUtils.format(payInfoDO.getGmtModified(), DateUtils.YMDHMS));
            if (PayInfoEnumConstants.ENUM_PAYTYPE_CUR.equals(payInfoDO.getPayType())) {
                returnParam.put("payMoney", payInfoDO.getPayCur().toString() + "积分");
            } else if (PayInfoEnumConstants.ENUM_PAYTYPE_BAL.equals(payInfoDO.getPayType())) {
                returnParam.put("payMoney", payInfoDO.getPayBalance().toString() + "元");
            } else {
                returnParam.put("payMoney", payInfoDO.getPayMoney().toString() + "元");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnParam;
    }

    /**
     * 通过支付单号ID查询订单编号，门店名称，积分支付类型
     *
     * @Author Vincentxin
     * @Date 2019/9/30 14:25
     * @param payId
     * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    @Override
    public Map<String, String> getOrderInfoCounterNameCurrencyType(String payId) {
        if (StringUtils.isEmpty(payId)){
            return null;
        }
        //查询支付表和订单关联表
        PayOrderRelDO payOrderRelDO = payOrderRelService.getRelBuyPayId(payId);
        //查询订单
        Map orderMap = orderFeign.getOrderForPay(payOrderRelDO.getOrderId());
        //通过收银台查询门店名称
        Map<String, Object> storeParams = new HashMap<>();
        if ("002".equals(payOrderRelDO.getOrderId().substring(4,7))){
            storeParams.put("counterId", counterId);
        }else{
            storeParams.put("counterId", orderMap.get("counterId").toString());
        }

        Map<String, String> shop = storeFeign.getStoreShopByCounterId(storeParams);

        Map<String,String> result = new HashMap<> ();
        result.put("storeName",shop.get("storename"));
        result.put("orderId",payOrderRelDO.getOrderId());
        if ("002".equals(payOrderRelDO.getOrderId().substring(4,7))){
            //代表是积分换购的积分支付
            result.put("currencyType", "0");
        }else{
            //代表够样优店的支付
            result.put("currencyType", "1");
        }
        return result;

    }

}
